/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Entidades.AutorEnt;
import Utilidades.Conexion;
import Utilidades.Constantes;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 *
 * @author usuario
 */
public class AutorDAO {
    
            Conexion con;
            Connection connect;
    
            public int ingresarAutor(AutorEnt autor) throws SQLException{
             
             con = new Conexion();
             connect = con.getCon();
             SimpleDateFormat dt = new SimpleDateFormat("yyyy/MM/dd"); 
             int idAutor = -1;
            try {
                
                    PreparedStatement st = connect.prepareStatement(Constantes.INGRESAR_AUTOR);
                
                    st.setString(1, autor.getNombre());
                    st.setString(2, autor.getStrFechaRealizacion());
                    
                    ResultSet rs = st.executeQuery();
                    if(rs.next()){
                        idAutor = rs.getInt(1);
                    }
                    
                    connect.close();
            } catch (SQLException ex) {
                Logger.getLogger(ObjetoAprendizajeDAO.class.getName()).log(Level.SEVERE, null, ex);
                connect.close();
            }
            
             
             
             return idAutor;
        }
    
}
